package org.dizem.intellipainter.component;

import javax.swing.*;
import java.awt.*;

/**
 * User: dizem@126.com
 * Time: 12-2-18 下午7:23
 */
public class StatusBar extends JPanel {
	private final JLabel statusLabel = new JLabel();
	private final JLabel cursorLabel = new JLabel();
	private static final Font FONT = new Font("微软雅黑", Font.PLAIN, 13);

	public StatusBar() {
		setLayout(new BorderLayout());
		statusLabel.setPreferredSize(new Dimension(450, 23));
		add(cursorLabel, BorderLayout.CENTER);
		add(statusLabel, BorderLayout.WEST);
		statusLabel.setForeground(Color.GRAY);
		statusLabel.setFont(FONT);
		cursorLabel.setForeground(Color.GRAY);
		cursorLabel.setFont(FONT);
	}

	public void setCursor(int x, int y) {
		if (x >= 0 && y >= 0) {
			cursorLabel.setText(String.format("当前坐标：(%d, %d)", x, y));
		} else {
			cursorLabel.setText("");
		}
	}

	public void setStatus(String status) {
		statusLabel.setText("   状态: " + status);
	}

}